#!/bin/bash

# 从远程JSON URL获取数据
json_url="https://gitlink.org.cn/api/attachments/2afa8701-273e-4047-bbd2-01ed72f6a2fd"
wget -O download.json --content-disposition "$json_url"

# 解析JSON获取包的URL
package_url=$(cat download.json | jq -r '.url')

# 下载包到指定文件夹
if [ -n "$package_url" ]; then
  echo "获取到最新下载链接:$package_url"
  echo "开始下载Darling"
  wget "$package_url"
  echo "下载完成"
  echo "开始安装"
  sudo apt install /opt/com.zhsoft.draling.runner/deb/*.deb
  echo "安装成功，按Enter退出"
  read -p "Press [Enter] to exit..."
else
  echo "Package URL not found in JSON data."
  read -p "Press [Enter] to exit..."
fi
